/*
    Bandleader
    Copyright (c) 2006 by Grant Yoshida

    Licensed under the GPL version 2 or later,
    please see COPYING for details.
*/

#ifndef Document_h
#define Document_h

#include "TimeSignature.h"
#include <QtCore/QStringList>

class QFile;
class QTextStream;

class Document : public QObject
{
    Q_OBJECT
public:
    Document();

    //
    //
    //

    QString fileName() const;
    const TimeSignature &timeSignature() const;

    //
    // Chords
    //

    QStringList chords() const;

    QString chordAt(int index) const;
    void setChord(int index, const QString &chord);
    void clearChord(int index);
    int numChords() const;

    void insertChord(int index, const QString &chord);
    void insertEmptyBar(int index);
    void insertEmptyBarAfter(int index);
    void deleteChord(int index);
    void deleteBar(int index);

    void insertChords(int index, const QStringList &chords);
    QStringList chordsInBar(int barNumber) const;

    int barNumberOf(int index) const;
    int indexOf(int barNumber) const;

    //
    // I/O
    //

    void saveAs(QFile &file);
    void saveAs(const QString &fileName);

signals:
    void nameChanged(const QString &name);

private:
    void saveAsMma(QTextStream &stream);
    void saveAsBandleader(QTextStream &stream);
    bool validChordIndex(int index) const;

private:
    QStringList m_chords;
    TimeSignature m_timeSignature;
    QString m_fileName;
};

#endif
